<?php

namespace System\Lib\Twitter\Auth;

/**
 * Description of Token
 *
 * @author Elton Schivei Costa
 */
class Token extends \System\Types\Object
{

    private $_key;
    private $_secret;

    /**
     * key = the token
     * secret = the token secret
     */
    function __construct(\System\Types\String $key, \System\Types\String $secret)
    {
        $this->_key = $key;
        $this->_secret = $secret;
    }

    /**
     * generates the basic string serialization of a token that a server
     * would respond to request_token and access_token calls with
     */
    function ToString()
    {
        return "oauth_token=" .
                Util::urlencode_rfc3986($this->_key->ToString()) .
                "&oauth_token_secret=" .
                Util::urlencode_rfc3986($this->_secret->ToString());
    }

    public function __set($var, $value)
    {
        $$var = $value;
    }

    public function __get($var)
    {
        $field = '_' . lcfirst($var);

        if (isset($this->{$field}))
        {
            return $this->{$field};
        }

        return null;
    }

}
